package com.hx.portal.controller.hospital;


import com.alibaba.dubbo.config.annotation.Reference;
import com.hx.common.result.PageResult;
import com.hx.common.result.Result;
import com.hx.hospital.pojo.Department;
import com.hx.hospital.service.DepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/department")
@Api(description = "科室相关接口")
public class DepartmentController {

    @Reference
    private DepartmentService departmentService;

    @GetMapping("/findDepartmentAll")
    @ApiOperation(value = "查询所有科室",notes = "查询所有科室",httpMethod = "GET")
    public List<Department> findDepartmentAll(){
        return departmentService.findDepartmentAll();
    }

    @GetMapping("/findDepartmentById")
    @ApiOperation(value = "根据查询科室",notes = "根据查询科室",httpMethod = "GET")
    public List<Department> findDepartmentById(Long id){
        return departmentService.findDepartmentById(id);
    }


    @GetMapping("/findAll")
    @ApiOperation(value = "查询所有",notes = "查询所有",httpMethod = "GET")
    public List<Department> findAll(){
        return departmentService.findAll();
    }

    @GetMapping("/findPage")
    public PageResult<Department> findPage(int page, int size){
        return departmentService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<Department> findList(@RequestBody Map<String,Object> searchMap){
        return departmentService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<Department> findPage(@RequestBody Map<String,Object> searchMap,int page, int size){
        return  departmentService.findPage(searchMap,page,size);
    }

    @GetMapping("/findById")
    public Department findById(Long id){
        return departmentService.findById(id);
    }


    @PostMapping("/add")
    public Result add(@RequestBody Department department){
        departmentService.add(department);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody Department department){
        departmentService.update(department);
        return new Result();
    }

    @GetMapping("/delete")
    public Result delete(Long id){
        departmentService.delete(id);
        return new Result();
    }

}
